package arrays;

import java.util.Scanner;

public class arrays_12 {
    public static void print_month(int month , int sum){
        int day ;
        switch ( month){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println( "\t\t\t" + month + "月");
                for (int i = 1; i <= 31; i++) {
                    System.out.print( i + "\t" );
                    if( i % 7 == 0){
                        System.out.println();
                    }
                }

            break;

            case 2:
                System.out.println( "\t\t\t" + month + "月");
                if(sum == 365){
                    day = 28 ;
                }else{
                    day = 29 ;
                }
                for (int i = 1; i <= day; i++) {
                System.out.print( i + "\t");
                if( i % 7 == 0){
                    System.out.println();
                }
            };
            break;

            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println( "\t\t\t" + month + "月");
                for (int i = 1; i <= 30; i++) {
                    System.out.print( i + "\t");
                    if( i % 7 == 0){
                        System.out.println();
                    }
                } ;
                break;

        }
    }
    public static void main (String [] args ){

        Scanner scanner = new Scanner(System.in) ;
        int year ;
        int sum = 365 ;
        System.out.println("请输入年份：");
        year = scanner.nextInt() ;
        if( ( year % 4 == 0 && year % 100 != 0) || year % 400 ==0 ){
            sum = 366 ;
        }
        for (int i = 1; i <= 12; i++) {
            print_month( i , sum );
            System.out.println();
        }

    }
}
